adds Topo! support and implements mkshort in .psp,
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 10 Oct 2002 17:16:43 +0000 (17:16 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 10 Oct 2002 17:16:43 +0000 (17:16 +0000)
.mxf, and .ozi.   From Alex Mottram.

gpsbabel/Makefile
gpsbabel/mxf.c
gpsbabel/ozi.c
gpsbabel/psp.c
gpsbabel/reference/tpg.tpg [new file with mode: 0644]
gpsbabel/testo
gpsbabel/vecs.c

index f132b4a2193f53cf8928978a76ef4e38b7234312..b83592c6b33d05021989282f3b6df7a2fc08ffb5 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS=-g -Icoldsync
 
 FMTS=magproto.o gpx.o geo.o gpsman.o mapsend.o mapsource.o \
        gpsutil.o tiger.o pcx.o csv.o cetus.o gpspilot.o magnav.o \
-       psp.o mxf.o holux.o garmin.o ozi.o dna.o
+       psp.o mxf.o holux.o garmin.o ozi.o dna.o tpg.o
 
 JEEPS=jeeps/gpsapp.o jeeps/gpscom.o jeeps/gpsfmt.o jeeps/gpsinput.o \
        jeeps/gpsmath.o jeeps/gpsmem.o  \
@@ -57,6 +57,7 @@ mapsource.o: mapsource.c defs.h queue.h
 mkshort.o: mkshort.c defs.h queue.h
 mxf.o: mxf.c defs.h queue.h csv_util.h
 ozi.o: ozi.c defs.h queue.h csv_util.h
+tpg.o: tpg.c defs.h queue.h
 pcx.o: pcx.c defs.h queue.h
 psp.o: psp.c defs.h queue.h
 queue.o: queue.c queue.h
index e5399b4673cb52dded238c2f9dc0ec817012e86c..412fa69a111d0171218742904fe590db448cd13c 100644 (file)
@@ -148,20 +148,30 @@ mxf_waypt_pr(const waypoint * wpt)
     char *shortname = NULL;
     char *description = NULL;
 
-    if (wpt->shortname) {
+    if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
+        if (wpt->description) {
+            if (global_opts.synthesize_shortnames)
+                shortname = mkshort(wpt->description);
+            else
+                shortname = csv_stringclean(wpt->description, ",\"");
+        } else {
+            /* no description available */
+            shortname = xstrdup("");
+        }
+    } else{
         shortname = csv_stringclean(wpt->shortname, ",\"");
-        shortname = csv_stringtrim(shortname, "");
-    } else {
-        shortname = xstrdup("");
     }
-    
-    if (wpt->description) {
+
+    if (! wpt->description) {
+        if (shortname) {
+            description = csv_stringclean(shortname, ",\"");
+        } else {
+            description = xstrdup("");
+        }
+    } else{
         description = csv_stringclean(wpt->description, ",\"");
-        description = csv_stringtrim(description, "");
-    } else {
-        shortname = xstrdup("");
     }
-    
+
     fprintf(file_out, "%08.5f, %08.5f, \"%s\", \"%s\", \"%s\", %s, %d\n",
            wpt->position.latitude.degrees, wpt->position.longitude.degrees,
            description, shortname, description, 
@@ -176,6 +186,12 @@ mxf_waypt_pr(const waypoint * wpt)
 static void 
 data_write(void)
 {
+    if (global_opts.synthesize_shortnames) {
+        setshort_length(32);
+        setshort_whitespace_ok(0);
+        setshort_badchars("\",");
+    }
+
     waypt_disp_all(mxf_waypt_pr);
 }
 
index 7fb507314a0a5ddf67f413df1db477f80250dd03..d04699bf78888d07e7c0592daa15e8c42dee6191 100644 (file)
@@ -183,15 +183,29 @@ ozi_waypt_pr(const waypoint * wpt)
     ozi_time = (wpt->creation_time / 86400.0) + 25569.0;
     alt_feet = (wpt->position.altitude.altitude_meters * 3.2808); 
     
-    if (wpt->description) 
-        description = csv_stringclean(wpt->description, ",");
-    else
-        description = xstrdup("");
-        
-    if (wpt->shortname) 
+    if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
+        if (wpt->description) {
+            if (global_opts.synthesize_shortnames)
+                shortname = mkshort(wpt->description);
+            else
+                shortname = csv_stringclean(wpt->description, ",");
+        } else {
+            /* no description available */
+            shortname = xstrdup("");
+        }
+    } else{
         shortname = csv_stringclean(wpt->shortname, ",");
-    else 
-        shortname = xstrdup("");
+    }
+
+    if (! wpt->description) {
+        if (shortname) {
+            description = csv_stringclean(shortname, ",");
+        } else {
+            description = xstrdup("");
+        }
+    } else{
+        description = csv_stringclean(wpt->description, ",");
+    }
 
     index++;
 
@@ -214,6 +228,12 @@ data_write(void)
     fprintf(file_out, "Reserved 2\n");
     fprintf(file_out, "Reserved 3\n");
 
+    if (global_opts.synthesize_shortnames) {
+        setshort_length(32);
+        setshort_whitespace_ok(0);
+        setshort_badchars("\",");
+    }
+
     waypt_disp_all(ozi_waypt_pr);
 }
 
index 1d94ebce3b1cbf620ab05eda07836bcd58621f7e..5e4773a8033a475d58d9e0741261a737eead07b9 100644 (file)
@@ -331,26 +331,30 @@ psp_waypt_pr(const waypoint *wpt)
        int i;
        char *shortname;
        char *description;
-       
 
-        /* this output format pretty much requires a description
-         * and a shortname 
-         */
-
-        if (wpt->shortname)  {
-            shortname = xstrdup(wpt->shortname);
-        } else {
-            if (wpt->description) 
-                shortname = xstrdup(wpt->description);
-            else 
+        if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
+            if (wpt->description) {
+                if (global_opts.synthesize_shortnames)
+                    shortname = mkshort(wpt->description);
+                else
+                    shortname = xstrdup(wpt->description);
+            } else {
+                /* no description available */
                 shortname = xstrdup("");
+            }
+        } else{
+            shortname = xstrdup(wpt->shortname);
         }
-                
-        if (wpt->description)  {
+
+        if (! wpt->description) {
+            if (shortname) {
+                description = xstrdup(shortname);
+            } else {
+                description = xstrdup("");
+            }
+        } else{
             description = xstrdup(wpt->description);
-        } else {
-            description = xstrdup(shortname);
-       }        
+        }
 
         /* convert lat/long back to radians */
        lat = (wpt->position.latitude.degrees * M_PI) / 180.0;
@@ -431,6 +435,11 @@ psp_write(void)
         /* offset 0x0C - 0x0D = 2 byte pin count */
 
         s = waypt_count();
+        
+        if (global_opts.synthesize_shortnames) {
+            setshort_length(32);
+            setshort_whitespace_ok(1);
+        }
 
         if (s > MAXPSPOUTPUTPINS) {
             fatal(MYNAME ": attempt to output too many pushpins (%d).  The max is %d.  Sorry.\n", s, MAXPSPOUTPUTPINS);
diff --git a/gpsbabel/reference/tpg.tpg b/gpsbabel/reference/tpg.tpg
new file mode 100644 (file)
index 0000000..a9a01a2
Binary files /dev/null and b/gpsbabel/reference/tpg.tpg differ
index 004048717d6697e5d287281516313d57ed467bfb..3078951423b4a1e12cac2aa2e2214c16d04f217c 100755 (executable)
@@ -93,6 +93,17 @@ ${PNAME} -i mxf -f reference/mxf.mxf -o mxf -F ${TMPDIR}/mx.mxf
 ${PNAME} -i mxf -f ${TMPDIR}/mx.mxf -o mxf -F ${TMPDIR}/mxf.mxf
 diff ${TMPDIR}/mxf.mxf reference
 
+# TPG (NG Topo!) file format
+# This is hard to test as the datum conversions create minute
+# inconsistencies in the coordinates.  So..  we test our i/o 
+# against a format that rounds higher than we care to compare
+# for binary data. 
+rm -f ${TMPDIR}/topo.mxf ${TMPDIR}/tpg.mxf ${TMPDIR}/geo.tpg
+${PNAME} -i geo -f geocaching.loc -o tpg -F ${TMPDIR}/geo.tpg
+${PNAME} -i tpg -f ${TMPDIR}/geo.tpg -o mxf -F ${TMPDIR}/tpg.mxf
+${PNAME} -i tpg -f reference/tpg.tpg -o mxf -F ${TMPDIR}/topo.mxf
+diff ${TMPDIR}/tpg.mxf ${TMPDIR}/topo.mxf
+
 # OZI (OziExplorer 1.1) file format
 rm -f ${TMPDIR}/oz.ozi ${TMPDIR}/ozi.ozi
 ${PNAME} -i ozi -f reference/ozi.ozi -o ozi -F ${TMPDIR}/oz.ozi
index db1e0691d97ddfbaa03f5a37d3257e772a033b69..2735bc5a507f41460a3e18de59d6fb1d77a9f6b4 100644 (file)
@@ -45,6 +45,7 @@ extern ff_vecs_t garmin_vecs;
 extern ff_vecs_t mxf_vecs;
 extern ff_vecs_t holux_vecs;
 extern ff_vecs_t ozi_vecs;
+extern ff_vecs_t tpg_vecs;
 extern ff_vecs_t dna_vecs;
 extern ff_vecs_t xmap_vecs;
 
@@ -145,6 +146,11 @@ vecs_t vec_list[] = {
                "ozi",
                "OziExplorer Waypoint"
        },
+       {
+               &tpg_vecs,
+               "tpg",
+               "National Geographic Topo .tpg"
+       },
 
         {
                NULL,